Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

247
Visualizações
Get JavaScript event "focusout"-direction?

I have a listt like

<ul>
    <li class="first"></li>
    <li></li>
    <li></li>
    <li></li>
    <li class="last"></li>
</ul>

Now if one uses the tab-key to move over this list, after the last item, the focus jumps to a specific point on the page. No Problem so far:

// using the 'focusout' eventListener:
if (event.target.classList.contains('last')) {
    document.querySelector('#go-here-after-last').focus();
}

Now, I need to achieve the same thing but in the other direction. I move the focus with SHIFT+TAB a stepping backward, and I hit the item with class "first".

Now focusout triggers everytime - but i need only the "focus out is triggered while going reverse"

looking into the event shows a event.relatedTarget, that seems to be the originally next target, but thats not safe to use in my case.

Is there a way to achieve something like a "reverse-focus-detection"?

Thank you

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda